package com.ssy.lingxi.after.sale.controller;

import com.ssy.lingxi.after.sale.api.model.vo.request.VerifyVO;
import com.ssy.lingxi.after.sale.model.vo.request.ReturnGoodsPageVO;
import com.ssy.lingxi.after.sale.model.vo.response.ReturnGoodsDetailVO;
import com.ssy.lingxi.after.sale.model.vo.response.ReturnGoodsQueryVO;
import com.ssy.lingxi.after.sale.service.IReturnGoodsPlatformService;
import com.ssy.lingxi.after.sale.service.IReturnGoodsService;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @menu 平台后台-售后管理-退货申请单
 * @author ds
 * @date 2021/12/2
 * @version 2.0.0
 */
@RestController
@RequestMapping("/as/platform/returnGoods")
public class ReturnGoodsPlatformController extends BaseController {

    @Resource
    private IReturnGoodsService returnService;
    @Resource
    private IReturnGoodsPlatformService returnGoodsPlatformService;

    /**
     * 待审核退货申请单-列表
     * @param httpRequest 请求
     * @param pageVO 分页查询条件
     * @return 待审核退货申请单-列表
     */
    @RequestMapping(value = "/pageToBeVerify", method = RequestMethod.POST)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeVerifyByPlatform(HttpServletRequest httpRequest, @Valid @RequestBody ReturnGoodsPageVO pageVO) {
        getPlatformUser(httpRequest);
        return returnGoodsPlatformService.pageToBeVerifyByPlatform(getSysUser(httpRequest), pageVO);
    }

    /**
     * 待审核退货申请单-审核申请单
     * @param httpRequest 请求
     * @param verifyVO 审核数据
     * @return 审核结果
     */
    @RequestMapping(value ="/verify", method = RequestMethod.POST)
    public Wrapper<Void> verify(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        getPlatformUser(httpRequest);
        return returnGoodsPlatformService.verifyByPlatform(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 待审核退货申请单-详情
     * @param httpRequest 请求
     * @param returnId 退货单id
     * @return 退货申请数据
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsDetailVO> getDetailPlatform(HttpServletRequest httpRequest,Long returnId) {
        getPlatformUser(httpRequest);
        return returnService.getDetailPlatform(getSysUser(httpRequest), returnId);
    }

}
